package cn.b.sky.shop.storage;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @Author: lidapeng
 * @Description:
 * @Date Created in 8/18/23 3:39 PM
 * @Modified By: lidapeng
 * Copyright(c) dbappsecurity.com.cn
 */
@Data
@EqualsAndHashCode
public class Progress implements Serializable {
    private long completed;
    private long total;


    public void addCompleted(long completed) {
        this.completed += completed;
    }

    public boolean isCompleted() {
        return completed == total;
    }

    public int getPercentage() {
        if (total != 0) {
            int progress = (int) (completed * 100 / total);
            return progress;
        }
        return 0;
    }
}
